package com.equinox.spring_sse.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sse1")
@CrossOrigin
public class SseController {
	@RequestMapping(value = "/data", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
	public String data() {
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return "模拟动态数据...." + Math.random();
	}

}
